Add another sortlistmodel test
authorMatthias Clasen <mclasen@redhat.com>
Fri, 24 Jul 2020 23:28:21 +0000 (19:28 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 24 Jul 2020 23:28:54 +0000 (19:28 -0400)
This tests the crash fix in f7b73b2e010960975.

testsuite/gtk/sortlistmodel.c

index 1da5c3d815d7ccc0fc2b6b655ae8bd7731c0c59c..8f323a5fb8794b48b2e11b71005fa3912eca1913 100644 (file)
@@ -518,6 +518,23 @@ test_incremental_remove (void)
   g_object_unref (removed);
 }
 
+static void
+test_out_of_bounds_access (void)
+{
+  GtkSortListModel *sort;
+  GListStore *store;
+  gpointer item;
+
+  store = new_store ((guint[]) { 4, 8, 2, 6, 10, 0 });
+  sort = new_model (store);
+
+  item = g_list_model_get_item (G_LIST_MODEL (sort), GTK_INVALID_LIST_POSITION);
+  g_assert_null (item);
+
+  g_object_unref (store);
+  g_object_unref (sort);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -537,6 +554,7 @@ main (int argc, char *argv[])
 #endif
   g_test_add_func ("/sortlistmodel/stability", test_stability);
   g_test_add_func ("/sortlistmodel/incremental/remove", test_incremental_remove);
+  g_test_add_func ("/sortlistmodel/oob-access", test_out_of_bounds_access);
 
   return g_test_run ();
 }